package com.ffyc.cemp.schedule;


import com.ffyc.cemp.services.service.IUserService;
import com.ffyc.cemp.tools.BloomFilterUtil;
import lombok.extern.slf4j.Slf4j;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.quartz.QuartzJobBean;

import java.util.Date;
import java.util.List;

@Slf4j
public class PreHotUsernameJob extends QuartzJobBean {

    @Autowired
    private IUserService ius;

    @Override
    protected void executeInternal(JobExecutionContext context) throws JobExecutionException {

//        log.debug("预热用户名:{}", ius.preHotUsername());
        List<String> usernames = ius.preHotUsername();

        //usernames.forEach(username->BloomFilterUtil.getInstance().add(username));

        for (String username : usernames) {
            BloomFilterUtil.getInstance().add(username);
        }
        log.debug("用户名预热布隆过滤器成功{}....", new Date());

    }
}
